package com.zoe.app;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author Zoe.Zhang
 * @date 2021/10/24
 * @description
 */
@RestController
public class SessionController {

    @Value("${server.port}")
    String port;

    @GetMapping("/set")
    public String set(HttpSession httpSession) {
        httpSession.setAttribute("zoe", "www.zoe.top");
        return port;
    }

    @GetMapping("/get")
    public String get(HttpSession httpSession) {
        String zoe = (String) httpSession.getAttribute("zoe");
        return zoe + ":" + port;
    }
}
